package com.example.helloword.source;

import android.util.Log;

import com.example.helloword.bean.Book;
import com.example.helloword.bean.Chapter;
import com.example.helloword.utli.JsoupUtli;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class BiqupaiNoveSource extends BaseNovelSource{
    @Override
    public String getIndex()  {
        return "https://www.biqupai.com";
    }

    @Override
    public String getSearchUrl(String searchName) {
        return getIndex() + "/search.php?keyword=" + searchName;
    }

    @Override
    public Book getBooks(Element element)  {
        Book book = new Book();
        book.setBook_name(JsoupUtli.getPropertyValue(element.select("a.result-game-item-title-link"), "title"));
        book.setBookurl(getIndex() + JsoupUtli.getPropertyValue(element.select("a.result-game-item-pic-link"), "href"));
        book.setImgurl(getIndex() + JsoupUtli.getPropertyValue(element.select("img.result-game-item-pic-link-img"), "src"));
        book.setLast_updated_time(element.select("p.result-game-item-info-tag").get(2).select("span").get(1).text());
        book.setLatest_chapters(element.select("a.result-game-item-info-tag-item").text());
        book.setAuthor(element.select("p.result-game-item-info-tag span").get(1).text());
//        Log.v("getGetGetItemConten1", book.toString());
        return book;
    }

    @Override
    public Chapter getChapters(Element element) {
        Chapter chapter = new Chapter();
        chapter.setChapter_url(getIndex() + JsoupUtli.getPropertyValue(new Elements(element), "href"));
        chapter.setName(element.text());
//        Log.v("getGetGetItemConten1", chapter.toString());


        return chapter;
    }
}
